const path = require('path');
const jwt = require('koa-jwt');
const { think } = require('thinkjs');
const isDev = think.env === 'development';

module.exports = [
  {
    handle: 'meta',
    options: {
      logRequest: isDev,
      sendResponseTime: isDev
    }
  },
  {
    handle: 'resource',
    enable: isDev,
    options: {
      root: path.join(think.ROOT_PATH, 'www'),
      publicPath: /^\/(static|favicon\.ico)/
    }
  },
  // {
  //   handle: 'trace',
  //   enable: !think.isCli,
  //   options: {
  //     debug: isDev
  //   }
  // },
  {
    handle: 'payload',
    options: {
      keepExtensions: true,
      limit: '5mb'
    }
  },
  // {
  //   handle: 'token-error',
  //   options: {}
  // },
  // {
  //   handle: jwt,
  //   options: {
  //     secret: think.config('jwt').secret
  //   }
  // },
  {
    handle: 'router',
    options: {}
  },
  'logic',
  'controller'
];
